﻿using BLL.Interfaces;
using DAL.DBInteractions;
using POCOS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL
{
    public class UserProfileServices : IUserProfileServices
    {

         private readonly IUnitOfWork _unitofwork;

         public UserProfileServices(IUnitOfWork unitofwork)
        {
            this._unitofwork = unitofwork;
        }


         public UserProfileServices()
         {

         }



        public IEnumerable<UserProfile> GetUserProfile()
        {
            return _unitofwork.UserporfileRepository.GetAll();
        }

        public UserProfile GetUserProfileById(int id)
        {
            return _unitofwork.UserporfileRepository.GetById(id);
        }

        public void CreateUserProfile(UserProfile userProfile)
        {

            _unitofwork.UserporfileRepository.Add(userProfile);
            _unitofwork.Commit();
        }

        public void UpdateUserProfile(UserProfile userProfile)
        {
            _unitofwork.UserporfileRepository.Update(userProfile);
            _unitofwork.Commit();
        }

        public void DeleteUserProfile(int id)
        {
            _unitofwork.UserporfileRepository.Delete(GetUserProfileById(id));
            _unitofwork.Commit();
        }

        public void SaveUserProfile()
        {
            _unitofwork.Commit();
        }
    }
}
